/*
Pyxis 2.0
Copyright 2010-2011 Thomas W. Holtquist

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

using System;
using System.Collections;

using Microsoft.SPOT;

using Skewworks.Pyxis.Kernel;

namespace Skewworks.Pyxis.GUI.Controls
{

    [Serializable]
    public class Container : Control
    {

        #region Variables

        protected internal ArrayList _children = new ArrayList();
        
        #endregion

        #region Properties

        public ArrayList Children
        {
            get { return _children; }
        }

        #endregion

        #region Public Methods

        public virtual void AddChild(Control child)
        {
            child.Parent = this;
            child.SetOffset(this, new point(Left, Top));
            _children.Add(child);
        }

        public virtual void ClearChildren()
        {
            _children.Clear();
        }

        public virtual Control GetChildAt(int index)
        {
            return (Control)_children[index];
        }

        public virtual void RemoveChild(Control child)
        {
            _children.Remove(child);
        }

        public virtual void RemoveChildAt(int index)
        {
            _children.RemoveAt(index);
        }

        #endregion

    }
}
